VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Get Freespace on > 2GB drives

Philip Decker  (1 Submission)   Windows API Call/Explanation   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This code will return the freespace on a drive even if it exceeds 2GB.

Inputs
Drive ie. "C:"

Assumes
I saw lots of calculations for drive sizes but this one works for me and does not require calculations at all. It will return what Windows shows under properties on a drive. It even shows mapped network drives properly. Hope this code helps someone.

Returns
Drive size.

Side Effects
None.

API Declarations
Dim FB, BT, FBT As Currency
Dim DriveSize As String
Const Gigabyte = 1073741824
Const Megabyte = 1048576
Dim retval As Long
Private Declare Function GetDiskFreeSpace_FAT32 _
Lib "kernel32" Alias "GetDiskFreeSpaceExA" _
(ByVal lpRootPathName As String, _
FreeBytesToCaller As Currency, BytesTotal _
As Currency, FreeBytesTotal As Currency) _
As Long

Rate Get Freespace on > 2GB drives (4(4 Vote))
Get Freespace on > 2GB drives.bas

Get Freespace on > 2GB drives Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters